/*
 * Email Notify
 * Copyright: (C) 2008 by Antonio Nastasi
 * Email: sifcenter (at) gmail.it
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef EMAILNOTIFY_H
#define EMAILNOTIFY_H

#include <KIcon>
#include <Plasma/Applet>
#include <Plasma/Svg>

#include <QTimer>
#include <Phonon/MediaObject>
#include "settings/configdialog.h"
#include "emailchecker.h"
#include "account.h"

class EmailNotify : public Plasma::Applet
{
  Q_OBJECT

  public:
                        EmailNotify( QObject *parent, const QVariantList &args );
                        ~EmailNotify();
    void                paintInterface( QPainter *painter,
                                const QStyleOptionGraphicsItem *option,
                                const QRect& contentsRect );
    void                init();

  private:
    KIcon               m_icon;
    QString             text_;
    KConfigGroup        generalGroup_;
    KConfig             *config_;
    QTimer              *timer_;

    // For play sound
    Phonon::MediaObject *media_;

    // For Configure Dialog
    ConfigDialog        *configDialog_;
    EmailChecker        *emailChecker_;
    Account             *account_;
    QList<QAction *>    contextualActions();
    QList<QAction *>    *listActions_;
    void                constraintsUpdated( Plasma::Constraints constraints );

  private slots:
    void                showConfigurationInterface();
    void                slotCheckEmails();
    void                playSound();
    void                setText( QString );
    void                updater();
    void                slotEmailsChanged(); // count of emails changed
    void                slotOpenEmailClient() const;

};

K_EXPORT_PLASMA_APPLET( emailnotify, EmailNotify )
#endif
